﻿using System;

namespace Calculator
{
    public class OperatorHandler : IOperatorHandler
    {
        public bool IsOperator(char c)
        {
            return c == '+' ||
                   c == '-' ||
                   c == '*' ||
                   c == '/';
        }

        public int GetPrecedence(char operatorParam)
        {
            switch (operatorParam)
            {
                case '*':
                case '/':    
                    return 10;
                case '+':
                case '-':
                    return 1;
            }
            throw new ArgumentException("Символ не является оператором");
        }

        public int GetPrecedence(string operatorParam)
        {
            switch (operatorParam)
            {
                case "*":
                case "/":
                    return 10;
                case "+":
                case "-":
                    return 1;
            }
            throw new ArgumentException("Символ не является оператором");
        }

        public bool IsOperator(string expression)
        {
            return
                expression == "+" ||
                expression == "-" ||
                expression == "*" ||
                expression == "/";

        }

        public bool IsNumber(string expression)
        {
            int x;
            return int.TryParse(expression, out x);
        }

        public bool IsNumber(char c)
        {
            return char.IsNumber(c);
        }
    }
}